import { useEffect, useState } from "react";
import { Select } from "antd";
import http from "@/http";

type optionItem = {
    label: string
    value: any
}
const { Option } = Select;
export default function EnumSelect(props: any) {
    const { selectKey } = props;
    const [options, setOptions] = useState<any[]>([]);
    const initSelectOptions = () => {
        http.httpGet('/mock/api/enum', { data: 1 }).then((data: any) => {
            setOptions(data);
        });
    }
    useEffect(() => {
        // 初始化select选择器
        initSelectOptions();
    }, []);
    return (
        <Select {...props}>
            {
                options.map((option: optionItem) => {
                    return <Option value={option.value} key={option.value}>{option.label}</Option>
                })
            }
        </Select>
    )
}